from PyQt5 import QtWidgets,QtCore


class Ui_MainWindow(object):
    def setupUi(self,MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(301,107)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)
        timer = QtCore.QTimer(MainWindow)
        timer.timeout.connect(self.showtime)
        timer.start()
    
    def showtime(self):
        datetime = QtCore.QDateTime.currentDateTime()
        text = datetime.toString("yyyy-MM-dd HH:mm:ss")
        self.statusbar.showMessage(text)
    
    def retranslateUi(self,MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow","MainWindow"))
    
import sys
if __name__ == "__main__":
    app = QtWidgets.QApplication(sys.argv)
    MainWindow = QtWidgets.QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    MainWindow.show()
    sys.exit(app.exec_())